package com.example.mvvmdemo.adapter;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

/**
 * User: Chentuisi
 * Date: 2023/8/7
 */
public abstract class MyDataViewAdapter<T,Binding extends ViewDataBinding> extends BaseQuickAdapter<T, BaseViewHolder> {
    private int selectedPosition = 0;

    public int getSelectedPosition() {
        return selectedPosition;
    }

    public void setSelectedPosition(int selectedPosition) {
        this.selectedPosition = selectedPosition;
    }

    public MyDataViewAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, T item) {
        onBindItem(DataBindingUtil.bind(helper.itemView), helper.getAdapterPosition(), item);
    }

    protected abstract void onBindItem(Binding binding, int position, T item);
}

